from flask import Flask, request
import json
import redis

app = Flask(__name__)

@app.route('/', methods=['POST'])
# 接收数据
def acceptData():
    info = json.loads(json.dumps(request.form))
    post_data = eval(list(info)[0])
    # print(post_data)
    send(post_data)
    return "1"

# 发布消息
def send(data):
    client = redis.Redis(host='39.105.153.251',password='@huqiao123')
    print(json.dumps(data))
    client.publish('dzyj.dzqrToxtjc', json.dumps(data))
    print("发送成功")



if __name__ == '__main__':
    app.debug = True
    app.run(host='0.0.0.0')